function add(formu) 
{
    qty=formu.quantity.value;
    productname=formu.product.value;
    stock=formu.stock.value;
    if(stock<=0){
        alert("We have run out of this product!\nStock: 0");
    }
    else{

            if (confirm("This product will be added: \n\n " + productname + " \n\nAre you sure?")) 
            {
                mem = 0;  
                mem = getcookie("order");
                mem++;
                if ( mem > 1 ) /*AQUI ESTABLECEMOS EL TAMAÑO DEL CARRITO (NUMERO MAXIMO DE ITEMS DISTINTOS)*/
                    alert("Eyyy!!!\nYour shooping cart is full...\n"+mem);
                else {

                    rfsh = formu.quantity.value + "|"  + formu.price.value  + "|" + formu.ref.value + "|" + 
                    formu.product.value;
                    nuevopedido = "Order." + mem;
                    setcookie (nuevopedido, rfsh, null, "/");
                    setcookie ("order", mem, null, "/");

		
                    info = "ADDING:\n\n" + "Quantity: " + qty + " \n"
                    + "Product: " + productname + "\n";
                    alert(info);
                }
            }
        }
    
}

function getcookieval (offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function getcookie (name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen)
    {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) return getcookieval (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}

function setcookie (name,value,expires,path,domain,secure) {
    document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}
